import request from '@/utils/request'
import request2 from '@/utils/request2'
import { faceApiUrl }  from "../config"

// 分页查询
export function getPageComBusinessCostMonthly(data) {
  return request({
    url: `${faceApiUrl}/comBusinessCostProjectPlanAdjust/getPage`,
    method: 'post',
    data
  })
}

// 详情接口
export function getComBusinessCostMonthlyById(data) {
  return request({
    url: `${faceApiUrl}/comBusinessCostMonthly/getComBusinessCostMonthlyById?id=${data.id}`,
    method: 'get',
  })
}

//导入数据-根据id
export function importMonthlyExcel(data) {
  return request2({
    url: `${faceApiUrl}/comBusinessCostMonthly/importMonthlyExcel`,
    method: 'post',
    data
  }).then(res =>{
    if(res.code=='200'){
    return Promise.resolve(res)
    }
    return Promise.reject(res);
    }).
    catch(err =>{
    return Promise.reject(err);
    })
}
//导出模板-根据id
export function exportMonthlyTemplate(data) {
  return request({
    url: `${faceApiUrl}/comBusinessCostMonthly/exportMonthlyTemplate`,
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}
// 获取调整总目标成本数据信息
export function getCostPlan(data) {
  let isShow = data.isShow === false?false:true;
  return request({
    url: `${faceApiUrl}/comBusinessCostProjectPlanAdjust/findById?id=${data.id}&isHide=${data.isHide}&isShow=${isShow}`,
    method: 'get',
    data
  })
}

// 上传调整总目标成本数据
export function editProjectTree(data) {
  return request({
    url: `${faceApiUrl}/comBusinessCostProjectPlanAdjust/editProjectTree`,
    method: 'post',
    data
  })
}

// 分解目标数据
export function addOrUpdateProjectTreeDetail(data) {
  return request({
    url: `${faceApiUrl}/comBusinessCostProjectTreeDetail/addOrUpdateProjectTreeDetail`,
    method: 'post',
    data
  })
}